//
//  BCBaseTabBarVC.swift
//  NewXueBa
//
//  Created by Shine on 2019/5/30.
//  Copyright © 2019 jmxQAQ. All rights reserved.
//

import Foundation
import ESTabBarController_swift

class BCNavigationVC: UINavigationController {
    
    override func pushViewController(_ viewController: UIViewController, animated: Bool) {
        if viewControllers.count > 0 { viewController.hidesBottomBarWhenPushed = true }
        super.pushViewController(viewController, animated: animated)
    }
    
}

class BCBaseTabBarVC {
    
    static func rootTabbarClass() -> ESTabBarController {
        //初始化tabBarController
        let tabBarController = ESTabBarController()
        // 消除 item之间的布局间隔
        if let tabBar = tabBarController.tabBar as? ESTabBar {
            tabBar.itemCustomPositioning = .fillIncludeSeparator
        }
        tabBarController.delegate = nil
        tabBarController.title = "Irregularity"
        //课程
        let courseVC = UIStoryboard.viewController(from: .CourseSB, viewControllerClass: CourseVC.self)
        courseVC.courseType = .AwaitClasss
        let navCourseVC = BCNavigationVC(rootViewController: courseVC)
        // 回放
        let lookBackVC = UIStoryboard.viewController(from: .CourseSB, viewControllerClass: CourseVC.self)
        lookBackVC.courseType = .LookBackClass
        let navLookBackVC = BCNavigationVC(rootViewController: lookBackVC)

        // 设置
        let setVC = UIStoryboard.viewController(from: .SetSB, viewControllerClass: SetTabVC.self)
        let navSetVC = BCNavigationVC(rootViewController: setVC)
        // 这个图片的类型是纯图片的  如果包含上图下文中会识别不出来  无法显示
        courseVC.tabBarItem = ESTabBarItem.init(BCIrregularityBasicContentView(), title: "课程", image: UIImage(named: "btn_course_nor"), selectedImage: UIImage(named: "btn_course_selected"))
        lookBackVC.tabBarItem = ESTabBarItem.init(BCIrregularityBasicContentView(), title: "回放", image: UIImage(named: "btn_history_nor"), selectedImage: UIImage(named: "btn_history_se"))
        setVC.tabBarItem = ESTabBarItem.init(BCIrregularityBasicContentView(), title: "设置", image: UIImage(named: "set_d"), selectedImage: UIImage(named: "set_s"))
        
        tabBarController.viewControllers = [navCourseVC, navLookBackVC, navSetVC]
        
        return tabBarController
    }
}
